/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aicue1.callbackhandlers;

import java.io.IOException;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.ws.security.WSPasswordCallback;

/**
 *
 * @author Thomas
 */
public class ClientPasswordCallbackHandler implements CallbackHandler {

    private String password = null;

    public ClientPasswordCallbackHandler(String password)
    {
        this.password = password;
    }

    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

        // set the password for our message.
        pc.setPassword(password);
    }

}
